using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace UsandoSprites2
{
    
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Nave nave;
        Meteoro meteoro;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferredBackBufferWidth = 1024;
            graphics.ApplyChanges();
            IsMouseVisible = true;

            base.Initialize();
        }

        protected override void LoadContent()
        {
            
            spriteBatch = new SpriteBatch(GraphicsDevice);

           nave = new Nave(Content.Load<Texture2D>("nave"), 
               new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2), 
                              new Point(128, 128), new Point(128, 128), 
                              new Point(1, 0), new Point(384, 128), 10, 10, 
                              new Vector2(4,4), 0);


           meteoro = new Meteoro(new Point(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), 
               Content.Load<Texture2D>("meteoro"),Vector2.Zero, new Point(464, 464), new Point(464, 464), 
                                  Point.Zero, new Point(8, 1), 0, 200, new Vector2(2, 2), 0.1f);

          }


        protected override void UnloadContent()
        {
           
        }

   
        protected override void Update(GameTime gameTime)
        {
            nave.Update(gameTime, Point.Zero);
           meteoro.Update(gameTime, Point.Zero);

            base.Update(gameTime);
        }


        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
            nave.Draw(gameTime, spriteBatch);
            meteoro.Draw(gameTime, spriteBatch);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
